//
//  RecordFooter.m
//  体育
//
//  Created by  on 2022/10/24.
//

#import "RecordFooter.h"
@interface RecordFooter()
@property (strong, nonatomic) IBOutlet UILabel *content;

@end
@implementation RecordFooter
- (void)awakeFromNib{
    [super awakeFromNib];
    CGRect bounds = CGRectMake(0, 0, SCREEN_WIDTH - 16, 30);
    UIBezierPath * path = [UIBezierPath bezierPathWithRoundedRect:bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(12, 12)];
    CAShapeLayer *layer = [CAShapeLayer layer];
    layer.frame = bounds;
    layer.path = path.CGPath;
    self.layer.mask = layer;
}
- (void)setArray:(NSArray *)array{
    _array = array;
    if ([self.title isEqualToString:LS(@"未来几场")]) {
        self.content.text = @"";
        return;
    }
    int num = 0;
    for (Record *model in array) {
        if ([model.home isEqualToString:self.title] && model.win) {
            num += 1;
        }else if ([model.from isEqualToString:self.title] && model.score_from > model.score_home){
            num += 1;
        }
    }
    NSString *str1 = [NSString stringWithFormat:LS(@"近%d场"),(int)array.count];
    NSString *str2 = [NSString stringWithFormat:LS(@"%d胜%d负"),(int)num, (int)array.count-num];
    NSString *str3 = [NSString stringWithFormat:LS(@"胜率%d%%"),(int)(num*100.0/array.count)];
    self.content.text = [NSString stringWithFormat:@"%@ %@ %@",str1,str2,str3];
}
@end
